/*
 * Copyright (C) 2012 Tomas Shestakov. <http://code.google.com/p/jmmo/>
 */

package jmmo.engine.property

/**
 * The root of alterable hierarchy.
 * Has identifier.
 * <p>
 * The Alterable is the class which can be altered (changed).
 * </p>
 * @author Tomas Shestakov
 */
trait Alterable extends Identifiable {

  def alter: PartialFunction[Alteration, Unit]
}

/**
 * Alterable which contains an observable value.
 * @tparam A type of alterable value
 * @author Tomas Shestakov
 */
trait AlterableValue[-A] extends Alterable {

  def update(value: A)
}

/**
 * Alterable which contains other alterables.
 * @author Tomas Shestakov
 */
trait AlterableContainer extends Alterable {

  /**
   * Search an child alterable with specified id's in this container.
   * If ids is empty returns self wrapped in Option.
   * @param ids identifiers of alterables to search.
   * @return child alterable with specified id wrapped in Option.
   */
  def alterable(ids: Identifier*): Option[Alterable]

  /**
   * @return Iterable collection of all alterable in this container.
   */
  def alterables: Iterable[Alterable]
}